package com.example.demo.service.impl;

import com.example.demo.dao.AdminbookDao;
import com.example.demo.entity.Adminbook;
import com.example.demo.service.AdminbookService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Adminbook)表服务实现类
 *
 * @author makejava
 * @since 2020-12-08 14:12:19
 */
@Service("adminbookService")
public class AdminbookServiceImpl implements AdminbookService {
    @Resource
    private AdminbookDao adminbookDao;

    /**
     * 通过ID查询单条数据
     *
     * @param adminbookId 主键
     * @return 实例对象
     */
    @Override
    public Adminbook queryById(Integer adminbookId) {
        return this.adminbookDao.queryById(adminbookId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<Adminbook> queryAllByLimit(int offset, int limit) {
        return this.adminbookDao.queryAllByLimit(offset, limit);
    }

    /**
     * 根据实例对象查询
     *
     * @param adminbook 实例对象
     * @return 对象列表
     */
    @Override
    public List<Adminbook> queryByExample(Adminbook adminbook) {
        return this.adminbookDao.queryAll(adminbook);
    }

    /**
     * 新增数据
     *
     * @param adminbook 实例对象
     * @return 实例对象
     */
    @Override
    public Adminbook insert(Adminbook adminbook) {
        this.adminbookDao.insert(adminbook);
        return adminbook;
    }

    /**
     * 修改数据
     *
     * @param adminbook 实例对象
     * @return 实例对象
     */
    @Override
    public Adminbook update(Adminbook adminbook) {
        this.adminbookDao.update(adminbook);
        return this.queryById(adminbook.getAdminbookId());
    }

    /**
     * 通过主键删除数据
     *
     * @param adminbookId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer adminbookId) {
        return this.adminbookDao.deleteById(adminbookId) > 0;
    }
}